package cn.mapway.ib;

import org.nutz.boot.NbApp;
import org.nutz.ioc.impl.PropertiesProxy;
import org.nutz.ioc.loader.annotation.*;
import org.nutz.lang.Lang;
import org.nutz.lang.Strings;
import org.nutz.lang.random.R;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.*;
import cn.mapway.ib.bean.User;
import org.nutz.dao.Dao;

@IocBean(create="init", depose="depose")
public class MainLauncher {
    
    @Inject
    protected PropertiesProxy conf;
    @Inject
    protected Dao dao;
    @At("/")
    @Ok("jsp:/jsp/index")
    public NutMap index() {
        NutMap map=new NutMap();
        map.setv("r",R.UU16());
        return map;
    }
    
    public void init() {
        // NB自身初始化完成后会调用这个方法
        dao.create(User.class, false);
        if (dao.count(User.class) == 0) {
            User user = new User();
            user.setName("wendal");
            user.setAge(18);
            user.setLocation("广州");
            dao.insert(user);
         }
    }
    public void depose() {}

    public static void main(String[] args) throws Exception {
        new NbApp().setArgs(args).setPrintProcDoc(true).run();
    }

}
